package Offer.offer2018;

import java.util.Stack;

/**
 * 两个栈实现队列
 * Created by 雷文康 on 2018/3/3.
 */
public class Test07 {

    Stack<Integer> stack1 = new Stack<>();
    Stack<Integer> stack2 = new Stack<>();

    public void add(int value) {
        stack1.add(value);
    }

    public int remove() {
        if (stack2.isEmpty()) {
            while (!stack1.isEmpty()) {
                stack2.push(stack1.pop());
            }
        }
        if (stack2.isEmpty()) {
            return -1;
        } else {
            return stack2.pop();
        }
    }

}
